import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/views/Layout'

const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      { path: '/', component: () => import('@/views/Home') },
      {
        path: '/goods/:id',
        component: () => import('@/views/Goods')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/Login')
  },
  {
    path: '/category/:id',
    component: () => import('@/views/Category')
  }
]

const router = createRouter({
  // 使用hash方式实现路由
  history: createWebHashHistory(),
  // 配置路由规则，写法和之前一样
  routes
})

export default router
